package com.example.contactapp.fragments;

import java.util.ArrayList;
import java.util.HashMap;

import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;

import com.example.contactapp.R;
import com.example.contactapp.adapters.SmsAdapter;
import com.example.contactapp.objects.SmsObject;
import com.example.contactapp.providers.SMSThread;

public class ChatFragment extends Fragment {
	private View v;
	private Activity activity;
	private SmsAdapter myAdapter;
	private HashMap<String, ArrayList<SmsObject>> mAllSmses;
	private ListView myLv;
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		v = inflater.inflate(R.layout.fragment_test, null);
		return v;
	}
	

	@Override
	public void onAttach(Activity activity) {
		// TODO Auto-generated method stub
		super.onAttach(activity);
		this.activity = activity;
	}
	
	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);

		init();
		
	}
	
	private void init() {
		myLv = (ListView) getView().findViewById(R.id.lv);
		mAllSmses = SMSThread.getInstance(activity).getAllSMS();
		myAdapter = new SmsAdapter(getActivity(), mAllSmses);
		myLv.setAdapter(myAdapter);
	}
	
}
